//
//  LWZBannerViewController.m
//  MusicFM
//
//  Created by 王景欣 on 16/1/12.
//  Copyright © 2016年 LWZ. All rights reserved.
//

#import "LWZBannerViewController.h"

@interface LWZBannerViewController ()

@property (nonatomic, copy) NSString *urlString;

@property (nonatomic, strong) UIWebView *webView;

@end

@implementation LWZBannerViewController

- (instancetype)initWithURL:(NSString *)urlString
{
    self = [super init];
    if (self) {
        self.urlString = urlString;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//    /** 改变navigationController的title颜色（系统没有提供方法） */
//    [self.navigationController.navigationBar setTitleTextAttributes:
//     
//     @{NSFontAttributeName:[UIFont systemFontOfSize:20],
//       
//       NSForegroundColorAttributeName:[UIColor whiteColor],
//       
//       }];
    self.navigationController.navigationBar.tintColor = [UIColor redColor];//
    [[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
    self.view.backgroundColor = [UIColor grayColor];
    
    /** 创建自定义button，让它替代系统的self.navigationItem.rightBarButtonItem */
    UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
    rightButton.size = CGSizeMake(30, 30);
    
    [rightButton setImage:[UIImage imageNamed:@"iconfont-fenxiang"] forState:UIControlStateNormal];
    
    [rightButton addTarget:self action:@selector(rightButtonDidPress:) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
    
    self.navigationController.navigationItem.rightBarButtonItem = rightItem;
    
    [self creatWebView];
}

#pragma mark - button 点击时间
- (void)rightButtonDidPress:(UIButton *)sender {
    NSLog(@"分享");
    
    
}

- (void)creatWebView {

    self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height + 20)];
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.urlString]];
    
    /** 适应界面 */
    self.webView.scalesPageToFit = YES;
    self.webView.scrollView.bounces =NO;
    [self.webView loadRequest:request];
    [self.view addSubview:self.webView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
